package com.hljcert.data.service.common.config;

/**
 * 通用业务异常
 */
public class BusinessException extends RuntimeException {

    private int code;

    public BusinessException(StatusEnum statusEnum, String msg) {
        super(msg);
        this.code = statusEnum.getCode();
    }

    public BusinessException(StatusEnum statusEnum, Throwable cause) {
        super(statusEnum.getMsg(), cause);
        this.code = statusEnum.getCode();
    }

    public BusinessException(StatusEnum statusEnum) {
        super(statusEnum.getMsg());
        this.code = statusEnum.getCode();
    }

    public int getCode() {
        return code;
    }

    public BusinessException setCode(int code) {
        this.code = code;
        return this;
    }
}
